#include "wx_pch.h"
#include "SongProperties.h"

#ifndef WX_PRECOMP
	//(*InternalHeadersPCH(SongProperties)
	#include <wx/intl.h>
	#include <wx/string.h>
	//*)
#endif
//(*InternalHeaders(SongProperties)
//*)

//(*IdInit(SongProperties)
const long SongProperties::ID_STATICTEXT1 = wxNewId();
const long SongProperties::ID_GRID1 = wxNewId();
const long SongProperties::ID_PANEL1 = wxNewId();
//*)

BEGIN_EVENT_TABLE(SongProperties,wxDialog)
	//(*EventTable(SongProperties)
	//*)
END_EVENT_TABLE()

SongProperties::SongProperties(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxSize& size)
{
	//(*Initialize(SongProperties)
	wxBoxSizer* BoxSizer2;
	wxBoxSizer* BoxSizer1;
	
	Create(parent, wxID_ANY, _("Song Properties"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX|wxMAXIMIZE_BOX, _T("wxID_ANY"));
	SetClientSize(wxSize(800,600));
	SetMinSize(wxSize(600,400));
	BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
	Panel1 = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
	BoxSizer2 = new wxBoxSizer(wxVERTICAL);
	StaticText1 = new wxStaticText(Panel1, ID_STATICTEXT1, _("Song properties"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
	BoxSizer2->Add(StaticText1, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	grdSongProperties = new wxGrid(Panel1, ID_GRID1, wxDefaultPosition, wxDefaultSize, 0, _T("ID_GRID1"));
	BoxSizer2->Add(grdSongProperties, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	Panel1->SetSizer(BoxSizer2);
	BoxSizer2->Fit(Panel1);
	BoxSizer2->SetSizeHints(Panel1);
	BoxSizer1->Add(Panel1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
	SetSizer(BoxSizer1);
	BoxSizer1->SetSizeHints(this);
	Center();
	//*)
}

SongProperties::~SongProperties()
{
	//(*Destroy(SongProperties)
	//*)
}

void SongProperties::showProperties() {
  grdSongProperties->CreateGrid((int)theSong->notes.size(), 8);
  grdSongProperties->SetColLabelValue(0, _("Pitch"));
  grdSongProperties->SetColLabelValue(1, _("Octave"));
  grdSongProperties->SetColLabelValue(2, _("Type"));
  grdSongProperties->SetColLabelValue(3, _("String"));
  grdSongProperties->SetColLabelValue(4, _("Fret"));
  grdSongProperties->SetColLabelValue(5, _("Keynumber"));
  grdSongProperties->SetColLabelValue(6, _("Frequency"));
  grdSongProperties->SetColLabelValue(7, _("Time"));
  int i;
  for(i = 0; i < (int)theSong->notes.size(); i++) {
    // pitch
    if(theSong->notes[i]->rest) {
      grdSongProperties->SetCellValue(i, 0, _("/"));
    } else {
      wxString tmpPitch = theSong->notes[i]->pitchString;
      if(theSong->notes[i]->flat)
        tmpPitch.Append(_("b"));
      if(theSong->notes[i]->sharp)
        tmpPitch.Append(_("#"));
      grdSongProperties->SetCellValue(i, 0, tmpPitch);
    }
    // octave
    grdSongProperties->SetCellValue(i, 1, wxString::Format(_("%d"), theSong->notes[i]->octave));
    // type
    grdSongProperties->SetCellValue(i, 2, wxString::Format(_("%d"), theSong->notes[i]->type));
    // string
    grdSongProperties->SetCellValue(i, 3, wxString::Format(_("%d"), theSong->notes[i]->string));
    // fret
    grdSongProperties->SetCellValue(i, 4, wxString::Format(_("%d"), theSong->notes[i]->fret));
    // keynumber
    grdSongProperties->SetCellValue(i, 5, wxString::Format(_("%d"), theSong->notes[i]->keyNumber));
    // frequency
    grdSongProperties->SetCellValue(i, 6, wxString::Format(_("%f"), theSong->notes[i]->frequency));
    // time
    grdSongProperties->SetCellValue(i, 7, wxString::Format(_("%d"), theSong->notes[i]->time));
  }
}
